package com.allen.imsystem.chat.mappers;

import com.allen.imsystem.chat.model.dto.ChatIdUidDTO;
import com.allen.imsystem.chat.model.vo.ChatSession;
import com.allen.imsystem.chat.model.vo.ChatSessionInfo;
import com.allen.imsystem.chat.model.vo.GroupMemberView;
import com.allen.imsystem.friend.model.param.InviteParam;
import com.allen.imsystem.chat.model.pojo.GroupChat;
import com.allen.imsystem.chat.model.vo.GroupView;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Repository
@Mapper
public interface GroupChatMapper extends BaseMapper<GroupChat> {

    /**
     * 查找群会话列表
     * @param uid 用户uid
     * @return 群会话列表
     */
    List<ChatSession> selectGroupChatList(String uid);

    /**
     * 查询某个群的群成员uid集合
     * @param gid 群id
     * @return 群成员uid集合
     */
    Set<String> selectGroupMemberIdSet(@Param("gid") String gid, @Param("status") Integer status);

    /**
     *
     * @param uid
     * @return
     */
    List<GroupView> findGroupViewListByUid(String uid);

    /**
     * 查询群成员列表
     * @param gid 群id
     * @return 群成员列表
     */
    List<GroupMemberView> selectGroupMemberList(String gid);

    @MapKey("myId")
    Map<String, ChatSession> selectGroupAllChatData(String gid);

    @MapKey("uid")
    Map<String, GroupChat> selectUserChatGroupRelationByUidList(@Param("list") List<InviteParam> list, @Param("gid") String gid);

    ChatSession selectOneGroupChatData(Long chatId);

    List<ChatIdUidDTO> findChatIdListByGidExcludeUid(@Param("uid")String uid, @Param("gid") String gid);

    Long selectChatIdByGidUid(@Param("gid")String gid, @Param("uid")String uid);

}
